package net.gagnat.android.trackit.domain;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

@SuppressWarnings("serial")
public class LogEntry implements Serializable {

	private Long id = null;
	private String description = null;
	private Calendar createdDate = null;
	private List<String> tags = new ArrayList<String>();

	public LogEntry() {
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Calendar getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Calendar createdDate) {
		this.createdDate = createdDate;
	}

	public List<String> getTags() {
		return tags;
	}

	public void addTag(String tag) {
		this.tags.add(tag);
	}

	@Override
	public String toString() {
		return df.format(createdDate.getTime()) + " " + description;
	}

	private static DateFormat df = new SimpleDateFormat("dd.MM.yy HH:mm");

	@Override
	public boolean equals(Object o) {
		if (this.id == null) {
			return false;
		}
		if (o instanceof LogEntry) {
			LogEntry other = (LogEntry) o;
			if (other.id == null) {
				return false;
			}
			return this.id.equals(other.id);
		}
		return false;
	}

	@Override
	public int hashCode() {
		if (this.id == null) {
			return super.hashCode();
		}
		return this.id.hashCode();
	}

}
